{template 'header', $module}
<div class="main-block bd-gray">
	<div class="hd fn-clear">
		<h2 class="fn-left">充值记录</h2>
	</div>
    <div class="main-nav fn-clear">
	<ul id="data-nav" class="fn-left fn-clear">
	{if $MOD[pay_online]}
		<li id="status_3"><a href="charge.php?action=pay&status=3">在线充值</a></li>
			{/if}
			<!--<li><a href="charge.php?action=card"><span>充值卡充值</span></a></li>-->
			{if $MOD[pay_url]}
			<!--<li><a href="{$MOD[pay_url]}"><span>银行汇款</span></a></li>-->
			{/if}
		<li id="status_1"><a href="charge.php?action=record&status=1">充值记录</a></li>
	</ul>
    <span class="overage">当前余额：<em class="cred">{$_money}</em>元</span>
    </div>
{if $action == 'record'}
<form action="?">
	<input type="hidden" name="action" value="{$action}"/>
	<div class="filter con fn-clear">
		<select class="fn-left mr20" name="bank">
		<option value="">支付平台</option>
			{loop $PAY $k $v}
			<option value="{$k}" {if $bank == $k}selected{/if}>{$v[name]}</option>;
			{/loop}
		</select>
		<p class="fn-left mr10">{Post::calender('fromtime', $fromtime, 'width:100')}</p>
		<span class="fn-left mr10">至 </span>
		<p class="fn-left mr10">{Post::calender('totime', $totime, 'width:100', true)}</p>
		<button class="btn fn-left mr10" type="submit">搜索</button>
		<button class="btn fn-left" type="reset" onclick="window.location='?action={$action}';">重置</button>
	</div>
</form>
	<table class="pay-log-tb mt10 c000 con">
		<thead>
		<tr>
			<th width="80">流水号</th>
			<th width="120">充值金额</th>
			<!--<th>手续费</th>-->
			<th width="80">实收金额</th>
			<th width="100">支付平台</th>
			<th width="150">下单时间</th>
			<th width="150">支付时间</th>
			<th width="60">状态</th>
		</tr>
		</thead>
		<tbody>
		{loop $charges $k $v}
		<tr>
			<td >{$v[itemid]}</td>
			<td >{$v[amount]}</td>
			<!--<td >{$v[fee]}</td>-->
			<td >{$v[money]}</td>
			<td>{$PAY[$v[bank]][name]}</td>
			<td class="c666">{$v[sendtime]}</td>
			<td class="c666">{$v[receivetime]}</td>
			<td>{$v[dstatus]}</td>
		</tr>
		{/loop}
		<tr align="center">
			<th>小计</th>
			<td >{$amount}</td>
			<td >{$fee}</td>
			<td >{$money}</td>
			<td colspan="3"></td>
		</tr>
		</tbody>
	</table>
<div class="pages">{$pages}</div>
{elseif $action == 'card'}
<form method="post" action="charge.php" onsubmit="return check_card();">
	<input type="hidden" name="action" value="card"/>
	<table class="data-form">
		<tr>
			<th width="90">卡号：</th>
			<td class="tr"><input type="text" name="number" size="20" id="number"/> <span id="dnumber" class="cred"></span></td>
		</tr>
		<tr>
			<th width="90">密码：</th>
			<td class="tr"><input type="text" name="password" size="20" id="password"/> <span id="dpassword" class="cred"></span>
			</td>
		</tr>
		<tr>
			<th width="90"></th>
			<td class="tr"><input type="submit" name="submit" value=" 充 值 " class="btn"/>
			</td>
		</tr>
</form>
</table>
<script type="text/javascript">
	function check_card() {
		if ( Dd('number').value.length < 8 ) {
			Dmsg('请填写正确的充值卡卡号', 'number');
			return false;
		}
		if ( Dd('password').value.length < 6 ) {
			Dmsg('请填写正确的充值卡密码', 'password');
			return false;
		}
	}
</script>
{elseif $action == 'pay'}
{if $MOD[pay_online]}
<table id="data-tb" class="data-form mt10">
<form method="post" action="charge.php" onsubmit="return check();" id="dform">
	<input type="hidden" name="action" value="confirm"/>
	<tbody class="pay-tb">
	<tr>
			<th width="90">* 充值金额</th>
			<td width="640">
				{if $charges}
				{loop $charges $k $v}
                <input class="nobd fn-left" type="radio" onclick="document.getElementById('other_amount').value=''" name="amount" value="{$v}" id="amount_{$k}"{if $k==0}checked{/if}/>
                <label class="fn-left mr5" for="amount_{$k}"> {$v}{$DT[money_unit]}</label>
				{/loop}
				<input class="nobd fn-left" type="radio" name="amount" value="0" id="amount_other"/>
                <label class="fn-left mr5" for='amount_other'> 其他金额（请填写大于0的整数）</label>
				<input class="fn-left" type="text" name="otheramount" size="10" value="{$amount}" id="other_amount" maxlength="8"/>
				{else}
				<input type="text" name="amount" size="10" value="{$amount}" id="amount" maxlength="8"/> {$DT[money_unit]}
                <span id="damount" class="cred"></span>
				{/if}
			</td>
		</tr>
		<tr>
			<th width="90">* 支付平台</th>
			<td width="640">

					{php $i=0;}
					{loop $PAY $k=>$v}
					{if $v[enable]}
					   <p class="mt5"><input class="fn-left nobd mr5 mt10"  type="radio" name="bank" value="{$k}" id="{$k}"{if $i==0} checked{/if}/>
				       <label for="{$k}"><img src="{SITE_URL}file/image/logo_{$k}.gif" alt=""/></label></p>
				{php $i=1;}
					{/if}
					{/loop}
					{if $i==0}
					<br/>抱歉，系统未设置支付平台，暂时无法在线充值
					{/if}
			</td>
		</tr>
		<tr>
			<td class="tl" height="50"></td>
			<td class="tr"><input type="submit" value=" 下一步 "  class="btn"{if $i==0} disabled{/if}/></td>
		</tr>
</form>
</tbody>
</table>
	{/if}
<script type="text/javascript">
function check() {
{if !$charges}
    if ( !Dd('amount').value ) {
        Dmsg('请填写充值金额', 'amount');
        return false;
    }
    {if $mincharge}
        if ( Dd('amount').value < {$mincharge} ) {
            Dmsg('金额最少{$mincharge}', 'amount');
            return false;
        }
    {/if}
{/if}
}
</script>
{elseif $action == 'confirm'}
	<table id="data-tb" class="data-form mt10">
	<form method="post" action="charge.php" target="_blank">
	<input type="hidden" name="action" value="confirm"/>
	<input type="hidden" name="amount" value="{$amount}"/>
	<input type="hidden" name="bank" value="{$bank}"/>
		<tbody class="pay-tb">
		<tr>
			<th width="90">支付平台</th>
			<td width="640"><img src="{SITE_URL}file/image/logo_{$bank}.gif" alt=""/></td>
		</tr>
		<tr>
			<th width="90">充值金额</th>
			<td width="640"><b class="c000">{$amount}</b> {$DT[money_unit]}</td>
		</tr>
<!--		<tr>
			<th width="90">手续费</th>
			<td width="640"><b class="c000">{$fee}</b> {$DT[money_unit]}</td>
		</tr>-->
		<tr>
			<th width="90">实收金额</th>
			<td width="640"><b class="cred">{$charge}</b> {$DT[money_unit]}</td>
		</tr>
		<tr>
			<th width="90">提示信息</th>
			<td width="640">
				- 点击确认充值，系统将跳转至第三方支付平台，支付成功后系统将自动为您入账。
				<br>- 如果在支付过程中遇到任何问题，请及时与客服中心取得联系，以便及时处理。
			</td>
		</tr>
		<tr>
			<th ></th>
			<td class="sub-info">
				<button id="J_Charge" class="btn" name="submit" type="submit">确认充值</button>
				<a class="btn"  onclick="history.back(-1);" style="cursor:pointer">返回修改金额</a>
			</td>
		</tr>
		</tbody>
	</form>
</table>
    <div id="J_PatDialog" class="pay-dialog fn-hide">
        <div class="dialog-bar"><a class="J_CloseDialog" href="javascript:void(0)" title="关闭">关闭</a></div>
        <p class="pay-tip"><i class="warn"></i>请您在新打开的页面上完成充值</p>
        <p>充值完成前请不要关闭此窗口。</p>
        <p>完成充值后请根据您的情况点击下面按钮：</p>
        <div class="buy-btns fn-clear">
            <a class="J_CloseDialog pay-btn" href="javascript:location.reload();">已完成充值</a>
            <a class="J_CloseDialog pay-btn" href="javascript:window.history.go(-1);">其他支付方式</a>
        </div>
    </div>
    <script>
        seajs.use(['$'],function($){
            $(".J_CloseDialog").click(function(){
                $("#J_PatDialog").hide();
            });
            $("#J_Charge").click(function(){
                $("#J_PatDialog").show();
            });
        });
    </script>
{else}
<table class="data-form">
	{if $charge_status == 2}
	<tr>
		<th width="90">充值结果</th>
		<td class="tr cred f_b px14">×充值异常</td>
	</tr>
	<tr>
		<td class="tl" height="50">相关说明</td>
		<td class="tr lh18">
			- 错误代码“{$charge_errcode}”，请与<a href="ask.php?action=add" class="b">客服联系</a>并告知错误代码。<br/>
			- <a href="charge.php?action=pay" class="b">重新充值请点这里。</a><br/>
		</td>
	</tr>
	{elseif $charge_status == 1}
	<tr>
		<th width="90">充值结果</th>
		<td class="tr f_green f_b px14">√ 充值成功，已经为您的帐户充值 <span class="cred">{$charge_amount}</span> {$DT[money_unit]}</td>
	</tr>
	<tr>
		<td class="tl" height="50">相关说明</td>
		<td class="tr lh18">
			- <a href="record.php?action=charge" class="b">查询记录请点这里。</a><br/>
			- <a href="charge.php?action=pay" class="b">继续充值请点这里。</a><br/>
		</td>
	</tr>
	{else}
	<tr>
		<td class="tl" height="50">充值结果</td>
		<td class="tr cred f_b px14">
			×充值失败
		</td>
	</tr>
	<tr>
		<td class="tl" height="50">相关说明</td>
		<td class="tr lh18">
			- 如果您确认充值成功，请立即<a href="ask.php?action=add" class="b">联系客服</a>解决。<br/>
			- <a href="charge.php?action=pay" class="b">重新充值请点这里。</a><br/>
		</td>
	</tr>
	{/if}
</table>
{/if}
</div>
<script type="text/javascript">
	seajs.use(['$','member'], function($,member){
		member.active('menu_money', '{$action}', 'status_{$status}');
        $(".pay-log-tb").find("tr:not(:last)").hover(function(){
            $(this).addClass("over");
        },function(){
            $(this).removeClass("over");
        });
	});
</script>
{template 'footer', $module}